#pragma once
#ifndef xFont_h__
#define xFont_h__
#include "xRes.h"
namespace Sky
{
	class xDxApp;
	class xFont : public xDeviceRes<ID3DXFont*>
	{
	public:
		xFont();
		~xFont();
	protected:
		virtual TResult onCreate(xDxApp* app);
		virtual TResult onDelete(xDxApp* app);
		//xRes
		virtual TResult onCreate(xDevice* device);
		virtual TResult onReset(xDevice* device) ;
		virtual TResult onLost(xDevice* device);
		virtual TResult onDelete(xDevice* device);
	private:
		TVoid Initialise();
		TVoid Finalise();
	public:
		static TVoid StaticInit(TInt height = 12,TUint width = 0,TUint weight = FW_LIGHT,
			TUint levels = 0,TBool bItalic = vFalse,TUint8 charSet = DEFAULT_CHARSET,
			TUint8 precision = OUT_DEFAULT_PRECIS,TUint8 quality = DEFAULT_QUALITY,
			TUint8 pitchAndFamily = DEFAULT_PITCH | FF_DONTCARE,TChar* faceName =(TChar*) TEXT("Arial"));
	public:
		ID3DXFont* getFont();
		xFont& setHeight(TInt height){m_Height = height;return *this;}
		xFont& setWidth(TUint width){m_Width = width;return *this;}
		xFont& setWeight(TUint weight){m_Weight = weight;return *this;}
		xFont& setMipLevels(TUint levels){m_MipLevels = levels;return *this;}
		xFont& setItalic(TBool bItalic){m_bItalic = bItalic;return *this;}
		xFont& setCharSet(TUint8 charSet){m_CharSet = charSet;return *this;}
		xFont& setPrecision(TUint8 precision){m_Precision = precision;return *this;}
		xFont& setQuality(TUint8 quality){m_Quality = quality;return *this;}
		xFont& setPitchAndFamily(TUint8 pitchAndFamily){m_PitchAndFamily = pitchAndFamily;return *this;}
		TInt   getTextWidth(TChar* str);
		TInt   getTextHeight();
		xFont& setFaceName(TChar* faceName)
		{
			TInt i = 0;
			do
			{
				m_FaceName[i] = *faceName;
			} while (i<sizeof(m_FaceName) && faceName != 0);
			return *this;
		}
	private:
		TInt		  m_Height;
		TUint		  m_Width;
		TUint		  m_Weight;
		TUint		  m_MipLevels;
		TBool		  m_bItalic;
		TUint		  m_CharSet;
		TUint		  m_Precision;
		TUint		  m_Quality;
		TUint		  m_PitchAndFamily;
		TChar		  m_FaceName[LF_FACESIZE];
	private:
		static TInt		ms_Height;
		static TUint	ms_Width;
		static TUint	ms_Weight;
		static TUint	ms_MipLevels;
		static TBool	ms_bItalic;
		static TUint	ms_CharSet;
		static TUint	ms_Precision;
		static TUint	ms_Quality;
		static TUint	ms_PitchAndFamily;
		static TChar	ms_FaceName[LF_FACESIZE];
	};
}
#endif // xFont_h__